package leeon.telnet;

import java.util.TooManyListenersException;

import ipworks.IPWorksException;
import ipworks.Telnet;
import ipworks.TelnetCommandEvent;
import ipworks.TelnetConnectedEvent;
import ipworks.TelnetConnectionStatusEvent;
import ipworks.TelnetDataInEvent;
import ipworks.TelnetDisconnectedEvent;
import ipworks.TelnetDoDoEvent;
import ipworks.TelnetDontEvent;
import ipworks.TelnetErrorEvent;
import ipworks.TelnetEventListener;
import ipworks.TelnetReadyToSendEvent;
import ipworks.TelnetSubOptionEvent;
import ipworks.TelnetWillEvent;
import ipworks.TelnetWontEvent;

public class TelnetBean {

	/**
	 * @param args
	 * @throws TooManyListenersException 
	 * @throws IPWorksException 
	 */
	public static void main(String[] args) throws TooManyListenersException, IPWorksException {
		Telnet telnet = new Telnet();
		telnet.addTelnetEventListener(new TelnetEventListener() {

			public void command(TelnetCommandEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void connected(TelnetConnectedEvent arg0) {
				// TODO Auto-generated method stub
				System.out.println(arg0.statusCode);
				System.out.println(arg0.description);
				
			}

			public void connectionStatus(TelnetConnectionStatusEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void dataIn(TelnetDataInEvent arg0) {
				// TODO Auto-generated method stub
				System.out.println(new String(arg0.text));
			}

			public void disconnected(TelnetDisconnectedEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void doDo(TelnetDoDoEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void dont(TelnetDontEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void error(TelnetErrorEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void readyToSend(TelnetReadyToSendEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void subOption(TelnetSubOptionEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void will(TelnetWillEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void wont(TelnetWontEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
		});
		
		telnet.connect("202.120.225.9");
		telnet.disconnect();
	}

}
